import pygame
from random import *

class FunnyEnemy(pygame.sprite.Sprite):
    def __init__(self, bg_size):
        pygame.sprite.Sprite.__init__(self)

        self.image = pygame.image.load("images/demo/滑稽.png").convert_alpha()

        self.destroy_images = []
        self.destroy_images.extend([
            pygame.image.load("images/small_basketball_down_1.png").convert_alpha(),
            pygame.image.load("images/small_basketball_down_2.png").convert_alpha(),
            pygame.image.load("images/small_basketball_down_3.png").convert_alpha()])

        self.rect = self.image.get_rect()
        self.width,self.height = bg_size[0],bg_size[1]
        self.speed = 2
        self.active = True
        self.mask = pygame.mask.from_surface(self.image)
        self.rect.left,self.rect.top =randint(0,self.width - self.rect.width),randint(-5*self.height,0)

    def move(self):
        if self.rect.top < self.height:
            self.rect.top += self.speed
        else:
            self.reset

    def reset(self):
        self.active = True
        self.rect.left,self.rect.top =randint(0,self.width - self.rect.width),randint(-5*self.height,0)

class CheckenEnemy(pygame.sprite.Sprite):

    energy = 8

    def __init__(self, bg_size):
        pygame.sprite.Sprite.__init__(self)

        self.image = pygame.image.load("images/demo/鸡头.png").convert_alpha()

        self.destroy_images = []
        self.destroy_images.extend([\
            pygame.image.load("images/mid_basketball_down_1.png").convert_alpha(),\
            pygame.image.load("images/mid_basketball_down_2.png").convert_alpha(),\
            pygame.image.load("images/mid_basketball_down_3.png").convert_alpha()])

        self.rect = self.image.get_rect()
        self.width,self.height = bg_size[0],bg_size[1]
        self.speed = 1
        self.active = True
        self.mask = pygame.mask.from_surface(self.image)
        self.rect.left,self.rect.top =randint(0,self.width - self.rect.width),randint(-10*self.height,-self.height)
        self.energy = CheckenEnemy.energy

    def move(self):
        if self.rect.top < self.height+5:
            self.rect.top += self.speed
        else:
            self.reset

    def reset(self):
        self.active = True
        self.energy = CheckenEnemy.energy
        self.rect.left,self.rect.top =randint(0,self.width - self.rect.width),randint(-10*self.height,-self.height)

